<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="address=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="browsermode" content="application" />
    <meta name="x5-page-mode" content="app" />
    <title>设置交易密码</title>
    <meta charset="utf-8" />
    <link href="../css/main.css?rev=@@hash" rel="stylesheet" />
    <style>
        body{
            width: 3.75rem;
            /*height: 6rem;*/
            background: url(../img/checkBg.png) no-repeat center;
            background-size: 100% 100%;  
        }
        .cells {
            height: 5.68rem;
            margin: 0 auto;
            position: static;
            top: 0;
            left: 0;
            transform: translate(0,0);
            box-shadow: 0 0 0 #fff;
            background: rgba(255, 255, 255, 0.8);
        }
        .cells_title {
            margin: 0;
            padding: .12rem .4rem;
            font-size: .16rem;
            height: .22rem;
            color: rgb(68,74,89);
        }
        .cells_title a {
            display: block;
            float: left;
            font-size: .16rem;
            height: .22rem;
            font-weight: 700;
        }
        .cells_title span {
            display: block;
            float: left;
            font-size: .13rem;
            height: .22rem;
            line-height: .22rem;
            margin-left: .2rem;
            color: rgb(136,136,136)
        }

        .operatorContent {
            width: 100%;
            margin-top: .98rem;
        }
        .txt {
            text-align: left;
            font-size: .12rem;
        }
        .cell{
            padding: .12rem .22rem .12rem;
        }
        .getCode {
            color: red;
            font-size: .12rem;
        }
        .cell_ft img {
            display: block;;
            width: .2rem;
            height: .1rem;
        }
        .tip {
            line-height: .2rem;
            height: .2rem;
            overflow: hidden;
            margin: .2rem .4rem;
        }
        .tip span{
            display: block;
            float: left;
            font-size: .12rem;
            line-height: .2rem;
            height: .2rem;
        }
        .tip i {
            display: block;
            width: .12rem;
            height: .12rem;
            margin: 0.02rem .04rem;
            float: left;
        }
        .tip i img {
            width: 100%;
        }
        .cells_tips {
            margin: 0rem .4rem;
            border-top: solid .01rem #eee;
            font-size: .12rem;
            height: .4rem;
            line-height: .4rem;
        }
        .submitBtn {
            position: static;
            margin: 0 auto;
            font-size: .15rem;
            background: #3276FE;
            border-radius: .25rem;
            box-shadow: 0 0.05rem 0.05rem rgb(255, 255, 255);
        }
        .cells_line {
            height: .1rem;
            width: 100%;
        }

        select {
            border: 0;
            float: right;
            width: 1.2rem;
            height: .2rem; 
            appearance:none;  
            -moz-appearance:none;  
            -webkit-appearance:none;  
            background: url("../images/gogogo.png") ;
            background-repeat: no-repeat;
            background-size: 20% 100%;
            background-position: 100% 0%;
            /*为下拉小箭头留出一点位置，避免被文字覆盖*/ 

            padding: 0 .14rem;
            font-size: .16rem;
        }
        select::-ms-expand { display: none; }
        select option {
            width: 1.2rem;
            height: .2rem; 
            font-size: .14rem;
            background-color: white;
        }
        .cell_cn img {
            position: absolute;
            top: .12rem;
            right: .4rem;
            width: .2rem;
            height: .2rem;
        }
        .tipsBell{
            width: .24rem;
            height: .24rem;
            margin-bottom: -.05rem;
        }
        .cells h6{
            color: #3276FE;
            font-size: .14rem;
            text-align: center;
            padding: .25rem 0;
        }
        .cell_hd {
            min-width: .1rem;
        }
        header{
            width: 100%;
            height: .44rem;
            line-height: .44rem;
            margin-bottom: .2rem;
        }
        header img,
        header span{
             display: inline-block;
             float: left;
        }
        header .backIcon{
            width: .24rem;
            height: .24rem;
            margin: .1rem 0 0 .16rem;
        }
        header .pageTitle{
            width: 80%;
            text-align: center;
            color: #fff;
            font-size: .17rem;
        }
        header .refresh{
            float: right;
            margin-right: .16rem;
            font-size: .14rem;
            color: #fff;
        }
    </style>
</head>
<body>
    <!-- 蒙版 -->
    <div class="layer_load">
        <div class="layer_mask"></div>
        <div class="layer_load_icon icon-loading"></div>
    </div>
    <!--<header>
            <a href="../index.html"><img class="backIcon" src="../img/backIcon.png" /></a>
            <span class="pageTitle">设置交易密码</span>
            <span class="refresh"></span>
    </header>-->
    <section class="cellsWrap">
        <div class="cells">
            <h6><img class="tipsBell" src="../img/tipsBell.png">设置交易密码是为了保障您的安全</h6>
            <div class="cell">
                <label class="cell_hd"><img class="tipsBell" src="../img/key.png"></label>
                <div class="cell_cn">
                    <input type="password" class="txt" placeholder="请输入6位交易密码"  maxlength="6" />
                </div>
            </div>
            <div class="cell">
                <label class="cell_hd"><img class="tipsBell" src="../img/key.png"></label>
                <div class="cell_cn">
                    <input type="password" class="txt" placeholder="请再次输入6位交易密码" maxlength="6" />
                </div>
            </div>
            <div class="operatorContent confirmBtn">
                <div class="submitBtn">
                    提交
                </div>
            </div>
        </div>
    </section>
    <!-- 脚本 -->
    <script src="../lib/zepto.min.js?rev=@@hash"></script>
    <script src="../js/main.js?rev=@@hash"></script>
    <script>
        (function(global,userUtil,layer){       
        	$("body").height(document.documentElement.clientHeight);
            var sessionId=userUtil.sid();
            var userUuid=userUtil.userID();
            var orderNo=localStorage.getItem("orderNo");
            // 提交/
            $(".submitBtn").click(function(){
                var password1=$(".cell_cn input").eq(0).val();
                var password2=$(".cell_cn input").eq(1).val();
                var reg = /^\d{6}\b/;
                console.log(reg.test(password1))
                if(!reg.test(password1)||!reg.test(password1)){
                    layer.tips("请输入6位交易密码");
                    $(".cell_cn input").eq(0).val("");
                    $(".cell_cn input").eq(1).val("");
                    return;
                }
                if(password1!=password2){
                    layer.tips("两次输入的密码不一致");
                    $(".cell_cn input").eq(0).val("");
                    $(".cell_cn input").eq(1).val("");
                    return;

                }else{
                    var _data={
                        "password": password1,
                        "userUuid": userUuid,
                        "sessionId": sessionId
                    };
                    $.ajax({
                        url: global.localUrl + "users/setPayPassword",
                        type: "post",
                        data: JSON.stringify(_data),
                        contentType: 'application/json;charset=utf-8',
                        success: function (re) {
                               if (1 == re.code) {
                                   layer.tips("设置成功");
                                   setTimeout(function(){
                                       //window.location.href=global.localUrl +"index.html";
                                       window.location.href="identification.html";
                                   },2000);
                               }else {
                                   layer.tips(re.message);
                               }
                           },
                                // $.ajax({
                                //     url: global.localUrl + "web/credit/submitCompletion",
                                //     type: "post",
                                //     data: JSON.stringify({"sessionId": sessionId,"orderNo":orderNo}),
                                //     contentType: 'application/json;charset=utf-8',
                                //     success: function (re) {
                                //         if (1 == re.code) {
                                //             layer.tips(re.message);
                                //             setTimeout(function(){
                                //                 window.location.href=global.localUrl +"index.html";
                                //             },2000);

                                //         }else {
                                //             layer.tips(re.message);

                                //         }
                                //     },
                                //     error: function () {
                                //         // layer.tips(global.netError);
                                //     }
                                // });
                        error: function () {
                            layer.tips(global.netError);
                        }
                    });
                }
            })
        })(global,userUtil,layer)
    </script>
</body>
</html>